using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Runtime.Serialization;
using System.Collections;
using System.Data;
using System.ComponentModel;
using System.Data.OracleClient;
using WPFExcelReport.Helpers;
using WPFExcelReport.Controls;
namespace WPFExcelReport
{

    public partial class VICC_WFSUBSCRIBER
    {
        public void SetUpNewRow(ref DataRow dwReturn)
        {

            switch (app.company)
            {
                case "YGR":
                case "YCC":
                default:
                    #region=========
                    dwReturn["MANDANT"] = "00";
                    dwReturn["ROWNID"] = INTEXDBC.GetSeq();
                    dwReturn["USERGROUP"] = "";
                    dwReturn["WFEUSER"] = "XKV     ";
                    dwReturn["WFEVENTS"] = "            ";
                    dwReturn["NEWUSER"] = "ITXV    ";
                    dwReturn["NEWTIME"] = "20141021";
                    dwReturn["CHGUSER"] = "ITXV    ";
                    dwReturn["CHGTIME"] = "20140917";
                    #endregion
                    break;
            }
        }

        public void InsertICC_WFSUBSCRIBER(DataRow dwData, string ITXDBVERSION = "50.24")
        {
            dwData["NEWUSER"] = app.User;
            dwData["NEWTIME"] = date; 
            or1 = OracleDB.CreateCommand(); 
            or1.CommandText = "INSERT INTO ICC_WFSUBSCRIBER(MANDANT,ROWNID,WFEUSER,WFEVENTS,NEWUSER,NEWTIME)"
                        + " VALUES (:MANDANT:,:ROWNID:,:WFEUSER:,:WFEVENTS:,:NEWUSER:,:NEWTIME:)"; 
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            Connect2Proxy(or1);
        }
        public void DeleteICC_WFSUBSCRIBER(DataRow dwData, int option = 1)
        {
            or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 1:
                    or1.CommandText = "DELETE FROM ICC_WFSUBSCRIBER WHERE  ROWNID=:ROWNID:"; ;
                    or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
                    break;
            }
            Connect2Proxy(or1);
        }
        public DataSet QueryICC_WFSUBSCRIBER(DataRow dwData, int option = 1)
        {

            or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 1:
                    or1.CommandText = "SELECT * FROM ICC_WFSUBSCRIBER WHERE  ROWNID=:ROWNID:"; ;
                    or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData); break;
                case 2:
                    or1.CommandText = "SELECT * FROM ICC_WFSUBSCRIBER WHERE MANDANT=:MANDANT: AND  WFEVENTS=:WFEVENTS:"; ;
                    or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
                    break;
                case 9999:
                    or1.CommandText = "SELECT * FROM ICC_WFSUBSCRIBER"; ;

                    break;
                default:
                    break;
            }
            SResult = Connect2Proxy(or1);
            SResult.Tables[0].TableName = TableName;
            return SResult;
        }
        public void UpdateICC_WFSUBSCRIBER(DataRow dwData, int option = 1)
        {
            or1 = OracleDB.CreateCommand();
            dwData["CHGUSER"] = app.User;
            dwData["CHGTIME"] = date;

            or1.CommandText = "UPDATE ICC_WFSUBSCRIBER SET  MANDANT=:MANDANT:, USERGROUP=:USERGROUP:, WFEUSER=:WFEUSER:, WFEVENTS=:WFEVENTS:, NEWUSER=:NEWUSER:, NEWTIME=:NEWTIME:, CHGUSER=:CHGUSER:, CHGTIME=:CHGTIME:"
                + " WHERE    ROWNID=:ROWNID: ";
            
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            Connect2Proxy(or1);
        }
    }
}
